package com.uui.service.user;

import java.util.HashMap;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.uui.bean.User;
import com.uui.mapper.user.UserMapper;

@Service
@Transactional
public class UserServiceImp implements UserService {
	Logger logger = Logger.getLogger(UserServiceImp.class);
	@Autowired
	UserMapper userMapper ;
	
	@Override
	public void addUser(User user) throws Exception {
		try {
			userMapper.addUser(user);
		} catch (Exception e) {
			throw new Exception("注册失败");
		}
	}

	@Override
	public Long getNextSeq(HashMap<String, Object> map) {
		Long nextSeq = userMapper.getNextSeq(map);
		logger.info(nextSeq);
		return nextSeq;
	}

	@Override
	public User getByUsername(String currentUsername) throws Exception {
		User user = null;
		try {
			user = userMapper.getByUsername(currentUsername);
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception("根据用户名查新信息失败");
		}
		return user;
	}

}
